import { redirect } from "next/navigation";

import { ReportsView } from "@/components/reports/reports-view";
import { getAuthenticatedUser, getProjectSummaries } from "@/lib/server-data";

export default async function ReportsPage() {
  const user = await getAuthenticatedUser();

  if (!user) {
    redirect("/auth/login");
  }

  const projects = await getProjectSummaries();

  return (
    <section className="mx-auto flex w-full max-w-5xl flex-col gap-6 px-6 py-12">
      <div className="flex flex-col gap-4">
        <h1 className="text-2xl font-semibold">报表中心</h1>
        <p className="text-sm text-muted-foreground">
          导出项目排产进度，用于每日/每周汇报。后续迭代将接入更多维度与图表、支持自定义筛选。
        </p>
      </div>
      <ReportsView initialProjects={projects} />
    </section>
  );
}
